Skip to content

Conversation

@Vidit-Ostwal
Copy link
Contributor

@Vidit-Ostwal Vidit-Ostwal commented Sep 25, 2025

This is a try solution for None / Empty response from LLM.

This PR assumes that this might be because of context length exceeded at the server side, which is not returning an error, just an empty response.
This PR captures the ValueError which is being raised and try again with summarization.


Note

Detect and handle null/empty LLM responses as context-window overflows, triggering summarization; update typings to BaseAgent and add focused tests.

  • Agents/Execution:
    • Treat null/empty LLM responses as potential context-window overflows via new is_null_response_because_context_length_exceeded and route to handle_context_length in CrewAgentExecutor and LiteAgent.
    • Add LLMMessage typing where needed.
  • Utilities:
    • Add is_null_response_because_context_length_exceeded(exception, messages, llm) in utilities/agent_utils.py.
    • Broaden is_context_length_exceeded docstring/signature; no behavioral regression.
  • Types/API:
    • Use BaseAgent in TaskEvaluator and update related imports/usages (e.g., tool utils typing).
  • Tests:
    • Add unit tests for null/empty response handling and new utility, plus executor integration test ensuring summarization path and final answer.

Written by Cursor Bugbot for commit da3f195. This will update automatically on new commits. Configure here.

@Vidit-Ostwal
Copy link
Contributor Author

Hey @lucasgomide, do you think this could be possible solution for this?
#2885 (comment)

I got some feedback from folks who tried the feature branch

@Vidit-Ostwal Vidit-Ostwal changed the title vo/fix/none_empty_response WIP Fix no response / null response from LLM Sep 27, 2025
cursor[bot]

This comment was marked as outdated.

cursor[bot]

This comment was marked as outdated.

@Vidit-Ostwal
Copy link
Contributor Author

Gentle ping on this one @lucasgomide

@lucasgomide
Copy link
Contributor

Added to my list to review later today

@Vidit-Ostwal Vidit-Ostwal force-pushed the Invalid_response_from_LLM branch from 3807072 to 5c9ac8f Compare October 30, 2025 12:44
cursor[bot]

This comment was marked as outdated.

cursor[bot]

This comment was marked as outdated.

@lucasgomide
Copy link
Contributor

mind you checking the CI errors?

@Vidit-Ostwal
Copy link
Contributor Author

mind you checking the CI errors?

All fixed now.

bool: True if the exception is due to context length exceeding
"""
if isinstance(exception, ValueError) and "None or empty" in str(exception):
return True
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug: Early return bypasses context length validation logic

The function is_null_response_because_context_length_exceeded has an early return that returns True for any ValueError with "None or empty" in the message, without checking if the context length was actually exceeded. This contradicts the function's purpose and the accompanying tests. For example, the test for empty messages expects False, and the test for messages smaller than the context window also expects False, but both will incorrectly return True due to this early return. The early return at lines 441-442 should be removed so only the final condition (which correctly validates all criteria) is used.

Fix in Cursor Fix in Web

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants